package top.glike.funct.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.glike.common.annotation.Log;
import top.glike.common.core.controller.BaseController;
import top.glike.common.core.domain.AjaxResult;
import top.glike.common.enums.BusinessType;
import top.glike.funct.domain.GbTravel;
import top.glike.funct.service.IGbTravelService;
import top.glike.common.utils.poi.ExcelUtil;
import top.glike.common.core.page.TableDataInfo;

/**
 * 旅行管理Controller
 * 
 * @author Sophia
 * @date 2024-02-13
 */
@RestController
@RequestMapping("/funct/travel")
public class GbTravelController extends BaseController
{
    @Autowired
    private IGbTravelService gbTravelService;

    /**
     * 查询旅行管理列表
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:list')")
    @GetMapping("/list")
    public TableDataInfo list(GbTravel gbTravel)
    {
        startPage();
        List<GbTravel> list = gbTravelService.selectGbTravelList(gbTravel);
        return getDataTable(list);
    }

    /**
     * 导出旅行管理列表
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:export')")
    @Log(title = "旅行管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GbTravel gbTravel)
    {
        List<GbTravel> list = gbTravelService.selectGbTravelList(gbTravel);
        ExcelUtil<GbTravel> util = new ExcelUtil<GbTravel>(GbTravel.class);
        util.exportExcel(response, list, "旅行管理数据");
    }

    /**
     * 获取旅行管理详细信息
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gbTravelService.selectGbTravelById(id));
    }

    /**
     * 新增旅行管理
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:add')")
    @Log(title = "旅行管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GbTravel gbTravel)
    {
        return toAjax(gbTravelService.insertGbTravel(gbTravel));
    }

    /**
     * 修改旅行管理
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:edit')")
    @Log(title = "旅行管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GbTravel gbTravel)
    {
        return toAjax(gbTravelService.updateGbTravel(gbTravel));
    }

    /**
     * 删除旅行管理
     */
    // @PreAuthorize("@ss.hasPermi('funct:travel:remove')")
    @Log(title = "旅行管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gbTravelService.deleteGbTravelByIds(ids));
    }
}
